﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Albums;
using VK.Comm.TransactSql;
using VK.Comm;
using VK.Casemeet.Photos;
using System.Data;

namespace VK.Casemeet.Web.Front
{
    public partial class AlbumDetail : System.Web.UI.Page
    {
        public AlbumEntity album = new AlbumEntity();

        protected void Page_Load(object sender, EventArgs e)
        {
            int albumID = Util.GetRouteDataInt("AlbumID");

            if (albumID != 0)
            {
                album = AlbumBLL.GetAlbum(albumID);
            }

            if (!IsPostBack)
            {
                aspNetPager.RecordCount = PhotoBLL.GetPhotoCount(GetCondition());
            }
        }

        protected void LoadData()
        {
            rptPhoto.DataSource = PhotoBLL.GetPhotoList(aspNetPager.StartRecordIndex, aspNetPager.EndRecordIndex, GetCondition(), null, SortMode.Desc);
            rptPhoto.DataBind();
        }

        protected IList<Condition> GetCondition()
        {
            IList<Condition> conditionlst = new List<Condition>();
            conditionlst.Add(new Condition { TableName = "Photo", FieldName = "ObjectType", ConditionType = ConditionType.NumeralEqual, ConditionValue = 3, DbType = DbType.Int32 });
            conditionlst.Add(new Condition { TableName = "Photo", FieldName = "ObjectID", ConditionType = ConditionType.NumeralEqual, ConditionValue = album.AlbumID, DbType = DbType.Int32 });
            return conditionlst;
        }

        protected void aspNetPager_PageChanged(object sender, EventArgs e)
        {
            LoadData();
        }
    }
}